layui.use(['form','layer','table','laytpl','laydate'],function(){
    var form = layui.form,
        layer = parent.layer === undefined ? layui.layer : top.layer,
        $ = layui.jquery,
        laytpl = layui.laytpl,
        table = layui.table,
        laydate = layui.laydate;


    //日期范围
    laydate.render({
        elem: '#dataselect'
        ,range: true
    });

    //用户列表
    var tableIns = table.render({
        elem: '#startBoxList',
        url : '../loginlog/getContinueList',
        cellMinWidth : 95,
        page : true,
        height : "full-125",
        loading:true,
        id : "startBoxList",
        cols : [[
            {field: 'userName', title: '微信名称', align:"center"},
            {field: 'userImg', title: '微信头像', align:'center',templet: function(d) {
                    return "<img src='"+d.userImg+"' onclick='showImg()' class='insImg' width='50px' height='50px' />"
                }},
            {field: 'openId', title: 'openId', align:"center"},
        ]]
    });
    //日期范围
    laydate.render({
        elem: '#dataselect'
        , range: true
    });

    //搜索【此功能需要后台配合，所以暂时没有动态效果演示】
    $(".search_btn").on("click",function(){
        tableIns.reload({
            page: {
                curr: 1 //重新从第 1 页开始
            },
            where: { //设定异步数据接口的额外参数，任意设
                type: $(".type").val(),
                userName:$(".userName").val()
            }
        })
    });


//列表操作
    table.on('tool(userList)', function (obj) {
        var layEvent = obj.event,
            //当前行数据
            data = obj.data;

        if (layEvent === 'edit') {
            editType(data);
        }
        if (layEvent === 'state') {
            editState(data);
        }
        if (layEvent === 'delete') {
            deleteById(data);
        }
    });
});